# yue.nicholas@gmail.com

ADD_EXECUTABLE ( eLut eLut.cpp )
ADD_CUSTOM_COMMAND(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/eLut.h
  COMMAND eLut ARGS > ${CMAKE_CURRENT_BINARY_DIR}/eLut.h
  DEPENDS eLut
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  )
SET_SOURCE_FILES_PROPERTIES(
  ${CMAKE_CURRENT_BINARY_DIR}/eLut.h
  PROPERTIES HEADER_FILE_ONLY TRUE
  )

ADD_EXECUTABLE ( toFloat toFloat.cpp )
ADD_CUSTOM_COMMAND(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/toFloat.h
  COMMAND toFloat ARGS > ${CMAKE_CURRENT_BINARY_DIR}/toFloat.h
  DEPENDS toFloat
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  )
SET_SOURCE_FILES_PROPERTIES(
  ${CMAKE_CURRENT_BINARY_DIR}/toFloat.h
  PROPERTIES HEADER_FILE_ONLY TRUE
  )

SET_SOURCE_FILES_PROPERTIES(
  half.cpp
  PROPERTIES
  OBJECT_DEPENDS
  "${CMAKE_CURRENT_BINARY_DIR}/eLut.h;${CMAKE_CURRENT_BINARY_DIR}/toFloat.h"
  )

IF(ILMBASE_BUILD_SHARED_LIBS)
    ADD_DEFINITIONS(-DHALF_EXPORTS)
ENDIF()

ADD_LIBRARY ( Half ${LIB_TYPE}
  half.cpp
  )


ADD_DEPENDENCIES ( Half toFloat eLut )

INSTALL ( TARGETS
  Half
  DESTINATION
  lib
)

INSTALL ( FILES 
  half.h
  halfFunction.h
  halfExport.h
  halfLimits.h
  DESTINATION
  include/OpenEXR
)
